package org.playground.booking.security.dao.Impl;

import org.hibernate.query.Query;
import org.playground.booking.auth.entity.Merchant;
import org.playground.booking.security.dao.IMerchantDao;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class MerchantDao extends AbstractDao<Merchant,Integer> implements IMerchantDao {
    @Override
    public Merchant loadMerchantByName(String name) {
        String hql = "from Merchant where name=:name";

        Query query = this.getCurrentSession().createQuery(hql);

        query.setParameter("name",name);

        List<Merchant> users = query.list();

        return users.size()==0?null:users.get(0);
    }
}
